<?php
require '../../lib/init.php';
$gCn=Con();

//Обекти
if ((int)$_GET['id'] > 0) {
    $objID = (int)$_GET['id'];



    $sql = 'SELECT o.*,c.name as client_name,
(SELECT object_id FROM objects WHERE orderby < o.orderby ORDER BY orderby DESC LIMIT 1) as idPrev,
(SELECT object_id FROM objects WHERE orderby > o.orderby ORDER BY orderby ASC LIMIT 1) as idNext
FROM objects o JOIN clients c ON o.client_id=c.client_id where o.object_id='.$objID.' ORDER BY orderby DESC;';

    $gCn->Execute($sql);
    $gCn->MoveFirst();
    if(!$gCn->mRs) exit;
    
    $smarty->assign('object_id',$gCn->mRs['object_id']);
    $smarty->assign('name',$gCn->mRs['name']);
    $smarty->assign('thumb_src',$gCn->mRs['thumb_src']);
    $smarty->assign('video_src',$gCn->mRs['video_src']);
    $smarty->assign('descr',nl2br(stripslashes($gCn->mRs['descr'])));
    $smarty->assign('client',$gCn->mRs['client_name']);
    $smarty->assign('category_id',$gCn->mRs['category_id']);
    $smarty->assign('type',$objects['type_id'][$gCn->mRs['type_id']]);
    $smarty->assign('type_id',$gCn->mRs['type_id']);
    $smarty->assign('year',$gCn->mRs['year']);

    $smarty->assign('idPrev',$gCn->mRs['idprev']);
    $smarty->assign('idNext',$gCn->mRs['idnext']);


    $smarty->display('object_popup.tpl');
}
//РЕКЛАМИ
else if((int)$_GET['bid'] > 0) {
    
    $bname = (int)$_GET['bname'];
    $id = (int)$_GET['bid'];
    trigger_error($id,E_USER_NOTICE);

    //$banner се декларира във файла /lib/banner_data.php
    // echo $bid;
    if($id>100) $data='data2'; else $data='data';
    
    $smarty->assign('page',             $banner[$bname]['page']);
    $smarty->assign('bname',            $bname);
    $smarty->assign('position',         $banner[$bname][$data][$id]['name']);
    $smarty->assign('size',             $banner[$bname][$data][$id]['size']);
    $smarty->assign('price',            $banner[$bname][$data][$id]['price']);
    $smarty->assign('impressions',      $banner[$bname][$data][$id]['imp']);
    $smarty->assign('impressionsRound', $banner[$bname][$data][$id]['impRound']);
    $smarty->assign('img',              $banner[$bname][$data][$id]['img']);
    $smarty->assign('descr',              $banner[$bname][$data][$id]['descr']);

    $smarty->display('reklama_popup.tpl');
}










?>
